import request from '../U9Request';
import { AuthLogin } from '../OAuth2';
import { AxiosPromise } from 'axios';
import { U9Result } from './type';

/**
 *
 * @param info
 * @param itemMaster
 * @param RunLaborHours
 * @param startDate
 * @returns
 */
export async function RunLaborHoursCreate(
  info: string,
  itemMaster: string,
  RunLaborHours: number,
  startDate: string,
): AxiosPromise<U9Result> {
  const res = await AuthLogin(info); // 获取token
  return request({
    url: '/webapi/StdWorkingHours/Create',
    method: 'post',
    headers: {
      token: res.data.Data,
    },
    data: [
      {
        OtherID: 'string',
        ID: 0,
        FromDate: startDate,
        ToDate: '9999.12.31',
        Department: {
          ID: 0,
          Code: '',
          Name: '',
        },
        ProductionLine: {
          ID: 0,
          Code: '',
          Name: '',
        },
        ItemMaster: {
          ID: itemMaster,
          Code: '',
          Name: '',
        },
        IdleHours: 0,
        RunLaborHours: RunLaborHours,
        RunMachineHours: 0,
        SetupLaborHours: 0,
        SetupMachineHours: 0,
        SrcRowID: 0,
      },
    ],
  }); // 修改工时
}
